Agent-first API design for parliamentary meeting data
Modern APIs designed for agent consumption require fundamentally different priorities than traditional human-developer interfaces. For a GraphQL API serving parliamentary meeting data, the transformation from human-first to agent-first design demands semantic precision, structural consistency, and machine-interpretable documentation while supporting diverse agent types from LLMs to web scrapers.
Core principles differentiate agent and human design
Agent-first API design prioritizes machine interpretability over developer convenience. Where human-focused APIs tolerate ambiguity through context and documentation, agent-first interfaces demand unambiguous semantic meaning in every field, consistent patterns across all endpoints, and self-describing capabilities through structured metadata. The shift represents moving from flexible, multi-path approaches that humans navigate intuitively to single, deterministic paths that machines can reliably traverse.
Parliamentary data presents unique challenges for agents. The hierarchical nature of Body → Organization → Meeting → AgendaItem structures requires deep query nesting that quickly exhausts LLM token limits. Temporal relationships between sessions, recurring agenda items, and policy evolution across meetings demand sophisticated time-series handling. Most critically, agents need semantic understanding of relationships between discussions, not just structural connections in the data model.
The existing OParl-based schema provides solid structural foundations with clear entity relationships and standardized field definitions. However, it lacks three critical agent-first capabilities: semantic search integration directly in the GraphQL layer, pre-computed aggregations for common analytical queries, and cross-meeting reference systems for tracking policy discussions over time. These gaps force agents to perform expensive post-processing rather than receiving analysis-ready data.
Successful government APIs demonstrate proven patterns
Analysis of leading parliamentary APIs reveals consistent design patterns that enable agent success. The UK Parliament API demonstrates comprehensive service decomposition with 10+ versioned APIs, each with complete OpenAPI specifications enabling automatic client generation. Their linked data architecture using semantic web technologies provides the cross-referencing capabilities missing from simpler implementations.
OpenStates pioneered dual-interface design, offering both REST and GraphQL endpoints to serve different agent types efficiently. Their flexible data retrieval through GraphQL enables precise field selection crucial for token-limited LLMs, while bulk data exports serve web scrapers and analysis tools. The standardized entity model across all 50 US states demonstrates how consistency enables generic client applications.
The GovInfo.gov API exemplifies relationship handling through its Related Documents Service, automatically discovering connections between bills, laws, and reports. Their progressive disclosure pattern—collections → packages → granules—allows agents to efficiently navigate from high-level summaries to detailed content without overwhelming initial queries.
Transform the schema with semantic intelligence layers
The current GraphQL schema requires three strategic enhancements to become agent-first. First, implement a semantic query layer that transcends structural navigation:
type Query {
findSimilarDiscussions(topic: String!, limit: Int): [AgendaItem]
searchAcrossMeetings(query: String!, dateRange: DateRange): SearchResults
getTopicTimeline(keywords: [String!]!): [TopicEvolution]
getRecurringTopics(organization: ID!, period: Period!): [RecurringTopic]
}
These queries enable agents to ask natural questions like “What other meetings discussed similar budget proposals?” without constructing complex nested queries. The semantic layer should leverage embeddings or full-text search to identify conceptually related content across the entire parliamentary corpus.
Second, add multi-resolution data fields to every major entity:
type Meeting {
id: ID!
briefSummary: String! # One-sentence for quick scanning
executiveSummary: String! # Paragraph for context
detailedMinutes: String! # Full content when needed
keyDecisions: [Decision!]! # Extracted actionable outcomes
speakerSummary: [SpeakerContribution!]! # Who said what
}
This pattern allows agents to progressively request more detail based on relevance, dramatically reducing token consumption for LLMs while maintaining full data availability for analysis tools.
Third, implement cross-referenced context fields that capture relationships beyond structural hierarchy:
type AgendaItem {
id: ID!
policyArea: PolicyArea! # Standardized categorization
stakeholders: [Stakeholder!]! # Affected parties identified
precedentItems: [AgendaItem!]! # Historical context
followUpItems: [AgendaItem!]! # Subsequent discussions
impactAssessment: ImpactSummary # Pre-computed analysis
}
Technical implementation serves diverse agent types
Different agent types require specialized technical patterns. For LLMs, implement query complexity scoring based on estimated token consumption, not just database load. The Shopify model of assigning point values (Objects: 1, Connections: 2 + returned items) should be adapted to consider response size in tokens. Configure field-level caching with shorter TTLs for dynamic data and longer caching for historical records.
Web scrapers need predictable access patterns through GET support for persisted queries, enabling URL-based access to GraphQL data. Implement deterministic query hashing so the same query always produces the same URL. Provide bulk export endpoints (/export/voting-records?format=jsonl&date_range=2024
) that bypass GraphQL complexity for large-scale data retrieval.
Analysis tools require specialized aggregation resolvers that push computation to the database rather than returning raw data. Support multiple export formats through content negotiation:
type Query {
analyticsData(
format: ExportFormat = JSON # JSON, CSV, PARQUET
aggregation: AggregationType
timeRange: TimeRange!
): AnalyticsResponse
}
Implement time-series specific pagination patterns with consistent cursors that remain stable even as new data arrives, crucial for longitudinal analysis of parliamentary proceedings.
Rate limiting and caching optimize multi-agent performance
Replace simple request-count limits with complexity-based rate limiting that accounts for query cost. Configure different limits per agent type: LLMs get lower complexity but higher frequency (100 points/minute), scrapers receive higher complexity but lower frequency (1000 points/hour), and analysis tools access very high complexity queries with restricted frequency (5000 points/5 minutes).
Implement multi-layer caching optimized for different access patterns. CDN-level caching serves public data to scrapers, application-level caching stores computed aggregations for analysis tools, and field-level caching with varied TTLs optimizes LLM token usage. Use the DataLoader pattern to prevent N+1 queries regardless of agent type.
Documentation and discovery enable autonomous agents
Transform documentation from human tutorials to machine-readable specifications. Enhance OpenAPI/GraphQL schemas with semantic extensions describing not just structure but purpose:
paths:
/proceedings:
get:
x-agent-context: >
Optimized for discourse analysis and sentiment tracking.
Results include structured metadata for speaker identification,
topic classification, and vote correlation.
Implement self-describing endpoints using HATEOAS principles adapted for GraphQL, where each response includes available actions and related resources. This enables agents to discover capabilities without external documentation:
{
"data": { "id": "meeting-2025-001" },
"_links": {
"agenda": "/meetings/2025-001/agenda",
"attendees": "/meetings/2025-001/attendees",
"decisions": "/meetings/2025-001/decisions"
}
}
Monitoring reveals agent behavior patterns
Track agent-specific metrics to optimize the API iteratively. Monitor query complexity distribution by agent type to identify optimization opportunities. Measure cache hit rates across different layers to tune TTLs. Analyze error patterns to improve agent resilience.
Common agent query patterns will emerge, such as LLMs frequently requesting summaries with speaker attributions, scrapers following chronological meeting sequences, and analysis tools aggregating voting patterns by party affiliation. Use these insights to create specialized query templates that pre-optimize common patterns.
Conclusion: Semantic intelligence transforms parliamentary data access
The transformation from human-first to agent-first API design for parliamentary data requires more than technical adjustments—it demands reimagining how machines understand democratic processes. By implementing semantic search capabilities, multi-resolution data fields, and cross-referenced relationships, the API evolves from a structural data store to an intelligent information service.
Success depends on three critical factors: semantic precision in every field and relationship, progressive disclosure patterns that optimize for different agent capabilities, and comprehensive machine-readable documentation that enables autonomous discovery and navigation. The proven patterns from UK Parliament, OpenStates, and GovInfo demonstrate these principles work at scale.
The recommended approach layers semantic intelligence atop the existing OParl structure, preserving investments while enabling new agent capabilities. Priority should focus on implementing the semantic query layer and multi-resolution fields, as these provide immediate value for all agent types. With these enhancements, the parliamentary meeting API transforms from a passive data repository to an active participant in democratic transparency, enabling agents to surface insights, track policy evolution, and enhance citizen engagement with government processes.
References
Primary Sources
GraphQL Documentation
- GraphQL Foundation. “GraphQL: A query language for your API.” Available at: https://graphql.org/
- GraphQL Foundation. “Schemas and Types.” GraphQL Learn. Available at: https://graphql.org/learn/schema/
- GraphQL Foundation. “Pagination.” GraphQL Learn. Available at: https://graphql.org/learn/pagination/
- GraphQL Foundation. “Performance.” GraphQL Learn. Available at: https://graphql.org/learn/performance/
- GraphQL Foundation. “Caching.” GraphQL Learn. Available at: https://graphql.org/learn/caching/
Government API Documentation
- UK Parliament. “Developer hub - UK Parliament.” Available at: https://developer.parliament.uk/
- Open States. “API v3 Overview.” Available at: https://docs.openstates.org/api-v3/
- U.S. Government Publishing Office. “GovInfo API - Related Document Service.” Available at: https://www.govinfo.gov/features/api-related-document-service
- OParl Initiative. “Home - OParl.” Available at: https://oparl.org/
- City of Bonn. “Ratsinformationssystem OParl-API.” Offene Daten Bonn. Available at: https://opendata.bonn.de/dataset/ratsinformationssystem-oparl-api
Technical Articles and Best Practices
Agent-First API Design
- The New Stack. “How To Prepare Your API for AI Agents.” Available at: https://thenewstack.io/how-to-prepare-your-api-for-ai-agents/
- Christian Posta. “Exposing OpenAPI as MCP Tools - Semantics Matter.” Available at: https://blog.christianposta.com/semantics-matter-exposing-openapi-as-mcp-tools/
- Andrew Blase Obrigewitsch. “Fixing the Limitation of Large Language Models with GraphQL.” Medium. Available at: https://medium.com/@fullStackDataSolutions/fixing-the-limitation-of-large-language-models-with-graphql-d3644f0dc47d
API Design Principles
- Postman. “What is API Design? Principles & Best Practices.” Available at: https://www.postman.com/api-platform/api-design/
- Stoplight. “How to Write API Documentation: a Best Practices Guide.” Available at: https://stoplight.io/api-documentation-guide
- Moesif. “REST API Design: Filtering, Sorting, and Pagination.” Available at: https://www.moesif.com/blog/technical/api-design/REST-API-Design-Filtering-Sorting-and-Pagination/
GraphQL Performance and Rate Limiting
- Shopify Engineering. “Rate Limiting GraphQL APIs by Calculating Query Complexity.” Available at: https://shopify.engineering/rate-limiting-graphql-apis-calculating-query-complexity
- GraphQL API Gateway. “Complexity-based Rate Limiting & Quotas for GraphQL APIs.” Available at: https://graphql-api-gateway.com/graphql-api-gateway-patterns/complexity-based-rate-limiting-quotas
- Marc-André Giroux. “A Guide to GraphQL Rate Limiting & Security.” Medium. Available at: https://medium.com/@xuorig/a-guide-to-graphql-rate-limiting-security-e62a86ef8114
- Escape Tech. “GraphQL Query Cost Analysis.” Available at: https://escape.tech/blog/graphql-query-cost-analysis/
Caching Strategies
- Apollo GraphQL. “Server-Side Caching.” Available at: https://www.apollographql.com/docs/apollo-server/performance/caching
- Hygraph. “GraphQL Caching - GraphQL Academy.” Available at: https://hygraph.com/learn/graphql/caching
- Apollo GraphQL Blog. “Automatic Persisted Queries and CDN caching with Apollo Server 2.0.” Available at: https://www.apollographql.com/blog/backend/performance/automatic-persisted-queries-and-cdn-caching-with-apollo-server-2-0/
Implementation References
GraphQL Libraries and Tools
- npm. “graphql-query-complexity.” Available at: https://www.npmjs.com/package/graphql-query-complexity
- TypeGraphQL. “Query complexity.” Available at: https://typegraphql.com/docs/complexity.html
- Buildkite. “GraphQL resource limits.” Available at: https://buildkite.com/docs/apis/graphql/graphql-resource-limits
Case Studies
- Samu Lang. “api.parliament.uk. Features, May 2018.” Medium. Available at: https://medium.com/@langsamu/api-parliament-uk-7b87597019a4
- Raul Jordan. “How My Team Won the Facebook GraphQL Hackathon.” Medium. Available at: https://medium.com/@rauljordan/how-my-team-won-the-facebook-graphql-hackathon-ff013c0200b1
- data.europa.eu. “OParl Use Case.” Available at: https://data.europa.eu/en/publications/use-cases/oparl
Mach! Den! Staat! Projects
- Bonn Municipal Research Assistant Documentation. Available at: https://codeberg.org/machdenstaat/stadt-bonn-oparl/src/branch/main/docs/municipal_research_assistant.md
- OParl-Lite GraphQL Schema. Available at: https://codeberg.org/machdenstaat/oparl-lite/raw/branch/main/schema.graphql